#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/un.h>

int main(int argc, char const *argv[])
{
    int sockfd = socket(AF_UNIX,SOCK_STREAM,0);
    if (sockfd < 0)
    {
        perror("socket err\n");
        return -1;
    }
    
    struct sockaddr_un addr;
    memset(&addr,0,sizeof(addr));
    addr.sun_family = AF_UNIX;
    strcpy(addr.sun_path,"unix_sock");

    if (connect(sockfd,(struct sockaddr*)&addr,sizeof(addr))==-1)
    {
        perror("connect err\n");
        return -1;
    }
    
    char buf[64]={0};
    while (1)
    {
        memset(buf,0,64);
        fgets(buf,64,stdin);
        send(sockfd,buf,64,0);
        
    }
    
    close(sockfd);

    return 0;
}
